% gauss.chr ================================================================
% constraint handling rules for naive gaussian elimination
% thom fruehwirth 910610,911213,920124,930602,931223
% complete for equalities, leaves equalities implicit, slow
% may loop if variables of the equations are unified 


handler gauss.

:- local (=:=)/2.

operator(100,xfx,equals).

constraints (=:=)/2, (equals)/2.

normalize @ 
A =:= B <=> 
	normalize(A,B,Poly,Const), 
	Poly equals Const.   	

eliminate @ 
[X*Coeff1|P1] equals C1 \ P equals C2 <=> delete(X*Coeff2,P,P2) | 
	is_div(Coeff2,Coeff1,C), 
	mult_const(eq0(C1,P1),C,eq0(C1C,P1C)),	
        add_eq0(eq0(C2,P2),eq0(C1C,P1C),eq0(C3,P3)),
	P3 equals C3.


:- ['math-utilities'].	% load auxiliary file


/*
:-      3 * X + 2 * Y - 4 * (3 + Z) =:= 2 * (X - 3) + (Y + Z) * 7 ,      
        2 * (X + Y + Z) =:= 3 * (X - Y - Z) , 
        5 * (X + Y) - 7 * X - Z =:= (2 + 1 + X) * 6.
Z = Z
Y = Y
X = X
Constraints:
(6) -11 * Z_g1647 =:= 11
(10) -7.0 * X_g1711 =:= 12
(11) 2.72727275 * Y_g1679 =:= 1.79220796

:-      3 * X + 2 * Y - 4 * (3 + Z) =:= 2 * (X - 3) + (Y + Z) * 7 ,      
        2 * (X + Y + Z) =:= 3 * (X - Y - Z).   
Z = Z
Y = Y
X = X
Constraints:
(5) -0.545454502 * X_g1651 + 2.72727275 * Y_g1619 =:= 2.72727275
(6) -11 * Z_g1587 =:= 11
*/

/* end of file gauss.chr ------------------------------------------------*/
